<?php
// +----------------------------------------------------------------------
// | ManniuCMS
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://manniuyun.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: heitao <cms@manniuyun.com>
// +----------------------------------------------------------------------

namespace app\mall\validate;

use think\Validate;

class MallGoods extends Validate{

    protected $rule = [
        'catid'             => ['require','token'],
        'goods_sn'          => ['alphaDash'],
        'goods_name'        => ['require'],
        'goods_thumb'       => ['require'],
        'goods_keywords'    => ['require'],
        'goods_brief'       => ['require'],
        'goods_img'         => ['require'],
        'shop_price'        => ['require','number'],
        'market_price'      => ['require','number'],
        'goods_stock'       => ['require','number'],
        'warn_stock'        => ['require','number'],
        'is_sale'           => ['require','number','in'=>'0,1'],
        'status'            => ['require','number','in'=>'0,1']
    ];

    protected $message  = [
        'catid.require' => '栏目必选',

        'goods_sn.alphaDash' => '商品编号只能由字母和数字下划线“_”及破折号“-”组成',

        'goods_name.require' => '商品名称必填',

        'goods_thumb.require' => '请上传缩略图',

        'goods_keywords.require' => '关键字必填',

        'goods_brief.require' => '商品简介必填',

        'goods_img.require' => '请至少上传一张商品图片',

        'shop_price.require' => '店铺价格必填',
        'shop_price.number' => '店铺价格只能是数字',

        'market_price.require' => '市场价必填',
        'market_price.number' => '市场价只能是数字',

        'goods_stock.require' => '商品库存必填',
        'goods_stock.number' => '商品库存只能是数字',

        'warn_stock.require' => '预警库存必填',
        'warn_stock.number' => '预警库存只能是数字',

        'is_sale.require' => '是否上架标识必选',
        'is_sale.number' => '是否上架标识必须为数字',
        'is_sale.in' => '是否上架标识的值必是0或1',

        'status.require' => '状态标识必选',
        'status.number' => '状态标识必须为数字',
        'status.in' => '状态标识的值必是0或1'
    ];
}